<template>
	<view>
		<view class="boxc">
			<view class="titem">
				<view style="font-size: 44rpx;">0</view>
				<view style="color: #424242;;">今日收益</view>
			</view>
			<view class="titem">
				<view style="font-size: 44rpx;">0</view>
				<view style="color: #424242;;">总收益</view>
			</view>
			<!-- <view class="titem">
				<view></view>
				<view></view>
			</view> -->
		</view>
		<view class="boxc2" style="display: flex;flex-direction: column;">
			<view style="display: flex;justify-content: space-between;align-items: center;">
				<view style="display: flex;align-items: center;">
					<view class="x"></view>
					<view>检测量统计</view>
				</view>
				<view style="font-size: 26rpx;color: #868282;" @click="tiaozhuan('/pages/device/analysis_list')">查看全部></view>
			</view>
			<view class="xian">

			</view>
			<view style="height: 500rpx;display: flex;justify-content: center;align-items: center;">
				<view class="charts-box">
					<qiun-data-charts type="line" :opts="opts" :chartData="chartData" />
				</view>
				<!-- <view class="" style="color: 828282;">
					暂无数据
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				datalist: {},
				chartData: {},
				//您可以通过修改 config-ucharts.js 文件中下标为 ['line'] 的节点来配置全局默认参数，如都是默认参数，此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
				opts: {
					color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
						"#ea7ccc"
					],
					padding: [15, 10, 0, 15],
					enableScroll: false,
					legend: {},
					xAxis: {
						disableGrid: true
					},
					yAxis: {
						gridType: "dash",
						dashLength: 2
					},
					extra: {
						line: {
							type: "straight",
							width: 2,
							activeType: "hollow"
						}
					}
				}
			}
		},
		onLoad() {
			this.getdata()
			// this.getServerData();
		},
		methods: {
			getdata(){
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				uni.request({
					url: this.global.url + 'api/device/device_data_info',
					method: 'POST',
					data: {
						clinic_id: uni.getStorageSync('clinic_id')
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							// 存用户信息
							// that.clinic_userinfo = result.data
							that.datalist = result.data
							that.getServerData()
							console.log(that.clinic_userinfo)
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'none'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				})
			},
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				});
			},
			getServerData() {
				let that = this
				//模拟从服务器获取数据时的延时
				setTimeout(() => {
					//模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
					let res = {
						categories: that.datalist.zxt.week,
						series: [{
								name: "收益金额",
								data: that.datalist.zxt.data
							}
						]
					};
					this.chartData = JSON.parse(JSON.stringify(res));
				}, 500);
			},
		}
	}
</script>

<style>
	page {
		background-color: #f4f4f4;
	}

	.titem {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 33%;

	}

	.boxc {
		width: 90%;
		margin: 0px auto;
		margin-top: 30rpx;
		display: flex;
		justify-content: space-around;
		background-color: #fff;
		padding: 20rpx;
		border-radius: 20rpx;
	}

	.boxc2 {
		width: 90%;
		margin: 0px auto;
		margin-top: 30rpx;
		background-color: #fff;
		padding: 20rpx;
		border-radius: 20rpx;
	}

	.x {
		border-left: 6px solid #2269d2;
		height: 18px;
		margin-right: 10rpx;
	}
	 .charts-box {
	    width: 100%;
	    height: 400rpx;
		margin-top: 30rpx;
	  }
</style>